package com.swagger.demo.controller;

import com.fasterxml.jackson.annotation.JsonView;
import com.swagger.demo.entity.User;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    /**
     * 使用@RequestMapping时，一定要设置method参数
     *
     * @param user
     * @return
     */
    @ApiOperation("注册人员信息")
    @RequestMapping(value = "/addUser", method = RequestMethod.POST)
    @JsonView(User.UserSimpleView.class)
    public User addUser(@RequestBody @JsonView(User.UserDetailView.class) User user) {
        return user;
    }

}
